import { service } from '@/utils/request'
import axios from 'axios'

/**
 * get请求
 * @param url
 * @param params
 * @returns {*}
 */
const get = (url, params) => {
  return service({
    url: url,
    method: 'get',
    params: params
  }).catch(function(thrown) {
    if (axios.isCancel(thrown)) {
      console.log('Request canceled', thrown.message)
    } else {
      // TODO
    }
  })
}

/**
 * post请求
 * @param url
 * @param data
 * @param params
 * @returns {*}
 */
const post = (url, data = {}, params = {}) => {
  return service({
    url: url,
    method: 'post',
    data: data,
    params: params
  })
}

export { get, post }
